Relational Model
Attributes
- Domain: Set of allowed values for each attribute
- Attribute values are normally atomic
- Attributes can be null
Relation Schema
-
, , … , are attributes -
= , , … , is a relation schema - instructor = (ID, name, dept_name, salary)
-
The current values of a relation are specified by a table.
-
Each row in a table is a tuple
-
The order of tuples (order of rows) doesn’t matter
Database
- Database consists of multiple relations
- Good Design:
- Avoid repetition of information
- Avoid null values
Keys
- Keys can be used to uniquely identify a tuple (A row in a table)
- K
R - A key consists of a subset of elements from a relation schema. (A key can have one or more column)
- Super Key: values for K are sufficient to identify all unique tuple of each possible relation
- Ex: {ID}, {ID,name}
- Candidate Key: a minimal super key
- Ex: {ID}
- Primary Key: Any candidate key can be used as a primary key, But it’s better to use a meaningful, stable, small key as a primary key
- It’s better to use {ID} as a primary key than {Name} because names are not stable
- Foreign Key: A value in one relation appearing in another relation
- Referencing Relation
- Referenced Relation